﻿using System;
using System.Collections.Generic;

namespace Faml.Frontend
{
    public static class OperatorPrecedence
    {        
        public static int Get(BinaryOperations op)
        {
            switch (op)
            {
                case BinaryOperations.And:
                case BinaryOperations.Or:
                    return 0;

                case BinaryOperations.GreaterThan:
                case BinaryOperations.LessThan:
                case BinaryOperations.GreaterThanOrEqual:
                case BinaryOperations.LessThanOrEqual:
                case BinaryOperations.Equal:
                case BinaryOperations.NotEqual:
                    return 1;

                case BinaryOperations.Add:
                case BinaryOperations.Subtract:
                    return 2;

                case BinaryOperations.Multiply:
                case BinaryOperations.Divide:
                case BinaryOperations.Modulo:
                    return 3;

                default:
                    throw new ApplicationException("Unexpected binary operation: " + op);
            }
        }
    }
}